﻿<phone:PhoneApplicationPage x:Class="WPNextPhone8.Views.PullDownRefreshPage"
                            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                            xmlns:WPNext="clr-namespace:WPNextTools.NControls;assembly=WPNextTools"
                            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                            xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
                            xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
                            DataContext="{Binding PullDownVM,
                                                  Source={StaticResource Locator}}"
                            FontFamily="{StaticResource PhoneFontFamilyNormal}"
                            FontSize="{StaticResource PhoneFontSizeNormal}"
                            Foreground="{StaticResource PhoneForegroundBrush}"
                            Orientation="Portrait"
                            SupportedOrientations="Portrait"
                            shell:SystemTray.IsVisible="True"
                            mc:Ignorable="d">
    <phone:PhoneApplicationPage.Resources>
        <Style x:Key="ScrollViewerStyle1" TargetType="ScrollViewer">
            <Setter Property="VerticalScrollBarVisibility" Value="Auto" />
            <Setter Property="HorizontalScrollBarVisibility" Value="Disabled" />
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="Padding" Value="0" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="BorderBrush" Value="Transparent" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ScrollViewer">
                        <Border Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="ScrollStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="00:00:00.5" />
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="Scrolling">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0"
                                                             Storyboard.TargetName="VerticalScrollBar"
                                                             Storyboard.TargetProperty="Opacity"
                                                             To="1" />
                                            <DoubleAnimation Duration="0"
                                                             Storyboard.TargetName="HorizontalScrollBar"
                                                             Storyboard.TargetProperty="Opacity"
                                                             To="1" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="NotScrolling" />
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Grid Margin="{TemplateBinding Padding}">
                                <ScrollContentPresenter x:Name="ScrollContentPresenter"
                                                        Content="{TemplateBinding Content}"
                                                        ContentTemplate="{TemplateBinding ContentTemplate}" />
                                <ScrollBar x:Name="VerticalScrollBar"
                                           Width="5"
                                           Height="Auto"
                                           HorizontalAlignment="Right"
                                           VerticalAlignment="Stretch"
                                           IsHitTestVisible="False"
                                           IsTabStop="False"
                                           Maximum="{TemplateBinding ScrollableHeight}"
                                           Minimum="0"
                                           Opacity="0"
                                           Orientation="Vertical"
                                           ViewportSize="{TemplateBinding ViewportHeight}"
                                           Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                                           Value="{TemplateBinding VerticalOffset}" />
                                <ScrollBar x:Name="HorizontalScrollBar"
                                           Width="Auto"
                                           Height="5"
                                           HorizontalAlignment="Stretch"
                                           VerticalAlignment="Bottom"
                                           IsHitTestVisible="False"
                                           IsTabStop="False"
                                           Maximum="{TemplateBinding ScrollableWidth}"
                                           Minimum="0"
                                           Opacity="0"
                                           Orientation="Horizontal"
                                           ViewportSize="{TemplateBinding ViewportWidth}"
                                           Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                                           Value="{TemplateBinding HorizontalOffset}" />
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="ListBoxStyle1" TargetType="ListBox">
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}" />
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="BorderBrush" Value="Transparent" />
            <Setter Property="Padding" Value="0" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBox">
                        <ScrollViewer x:Name="ScrollViewer"
                                      Background="{TemplateBinding Background}"
                                      BorderBrush="{TemplateBinding BorderBrush}"
                                      BorderThickness="{TemplateBinding BorderThickness}"
                                      Foreground="{TemplateBinding Foreground}"
                                      Padding="{TemplateBinding Padding}"
                                      Style="{StaticResource ScrollViewerStyle1}">
                            <ItemsPresenter />
                        </ScrollViewer>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </phone:PhoneApplicationPage.Resources>


    <!--  LayoutRoot is the root grid where all page content is placed  -->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <WPNext:PullDownToRefreshPanel x:Name="RefreshPanel" />
        <ListBox x:Name="PullDownList"
                 ItemsSource="{Binding Codes}"
                 ScrollViewer.ManipulationMode="Control"
                 Style="{StaticResource ListBoxStyle1}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid Width="480" Background="DarkGray">
                        <TextBlock HorizontalAlignment="Center"
                                   FontSize="40"
                                   Foreground="Blue"
                                   Text="{Binding Mode=OneWay}" />
                    </Grid>

                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>

</phone:PhoneApplicationPage>